<?php 
ini_set('display_errors', 1); 
ini_set('error_reporting', 'E_error'); 
 require_once "../includes/config.php";
$cond = '';
$sort = '';
$ut = $u = $fn = $ln = $dg = 'asc';
if(isset($_GET['sort']))
{
 if($_GET['sort']=='shipping_name')
 {
  if($_GET['s_type']=='asc')
  {	$cond=' ORDER BY shipping_name ASC';	$sort = '&sort=shipping_name&s_type=asc';	$ut='desc';	}
  else
  {	$cond=' ORDER BY shipping_name DESC';	$sort = '&sort=shipping_name&s_type=desc';	}
 }
  
}
 


 ?>
<script type="text/javascript">
function update_service(service_id)
{
      window.location="index.php?edit_service&service_id="+service_id;
}
</script>
<form action="" method="post" name="formService" id="formService"> 
<table width="100%"  border="1" cellspacing="0" class="container">
  <tr>
    <td width="469" height="25" class="tdHeader">Shipping Service <span style="text-align:right; padding-left:350px;"><input type='button' name='addsscat' value='Add Service' class='button' onclick="update_service(0);" /></span></td>
  </tr>  
  <tr>
    <td height="577">
       <table width="100%">
	    <tbody>
		<tr>
		  <td>
		    <form name="frmSearchPro" action="" method="post">
		    <table width="100%" border="0">
			    <tr>
				    <td width="30%">Shipping Name</td>
				    <td width="70%">
					    <input type="text" name="shipping_name" id="shipping_name" value="<?php echo $_POST['shipping_name']; ?>" />
				    </td>
			    </tr>
			    

			    <tr>
				    <td height="35" colspan="5" style="text-align:center"><input type="submit" name="btnSearchPro" value="Search" /></td>
			    </tr>
		    </table>
		    </form>
		  </td>
		</tr>
		<tr>
		     <td>
			    <b>Sort  By :</b>
			    <a href="<?php echo $base_url;?>admin/index.php?list_service&sort=shipping_name&s_type=<?php echo $ut;?>">Name</a> &nbsp;&nbsp;&nbsp;
			 
			 
		     </td>
		</tr>
		</tbody>
	</table><br>
	<table width="100%"  border="0" cellspacing="0">
	 <tr>
	   <td height="27"  class="line">&nbsp;</td>
	   <td class="line">&nbsp;</td>	   
	   <td colspan="3"  class="line" style="text-align:right;">
	   		
		</td>
	 </tr>
	 <tr class="InnerHeader">
	   <td width="1%"  class="line">&nbsp;</td>
	   <td width="40%" class="line">Name</td>
	   <td width="41%" class="line">Description</td>
	   <td width="9%" class="line"></td>
	   <td width="9%" class="line"></td>
	 </tr>	 
	 <?php
	 
	      $search='';
	      if(isset($_POST['btnSearchPro'])) {
		      
		     $shipping_name 	= $_POST['shipping_name'];		
	     
		     if($shipping_name!='')
		     $search.= "where shipping_name='".$shipping_name."'";
	      }
	      $sqlShwSubcat="select * from tbl_shipping_service $search $cond";
	      $rstShwSubcat=mysql_query($sqlShwSubcat);
	      $numShwSubcat=mysql_num_rows($rstShwSubcat);
	      if($numShwSubcat==0) 
	      {
		     echo "<tr><td></td><td colspan='4'><h3>No Shipping Service Found...</h3></td></tr>";
	      }
	      else 
	      {
		     while($rowShwSubCat=mysql_fetch_array($rstShwSubcat)) 
		     {
			    $subcatId=$rowShwSubCat['shipping_id'];
			    $subcatName=$rowShwSubCat['shipping_name'];
			    $subcatDesc=$rowShwSubCat['shipping_description'];				
			    echo "<tr>";
			    echo "<td class='line'>&nbsp;</td>";
			    echo "<td class='line'>$subcatName</td>";
			    echo "<td class='line'>$subcatDesc</td>";
			    echo "<td class='line'><input type='button' name='edit' value='Edit' class='button' onclick='update_service($subcatId);'></td>";
			    echo "<td height='20' class='line'></td> ";
			    echo "</tr>";
		     }
	      }
		 ?>
	 <tr>
		   <td>&nbsp;</td>
		   <td>&nbsp;</td>
		   <td>&nbsp;</td>
		   <td></td>
		   <td></td>
	  </tr>
	</table>
</td>
</tr>
</table>
</form>